Learn R Programming

MXM (version 0.9.5)

Neighbours of nodes in an undirected graph: Returns and plots, if asked, the node(s) and their neighbour(s), if there are any.

Description

Returns and plots, if asked, the node(s) and their neighbour(s) of one or more nodes (if there are any).

Usage

nei(G, node, graph = TRUE)

Arguments

G
The adjacency matrix of an undirected graph as produced by mmhc.skel, pc.skel or any other algorithm.
node
A vector with one or more numbers indicating the seleted node(s) (or variable(s)).
graph
A boolean variable. If TRUE the relevane graph will appear (if there are neighbours).

Value

A list object called "geit" containing the neighbours of the node(s). If there are no neighbours a message appears and no plot is presented. If the "graph" argument is set to TRUE and there are neighbours, a plot will appear.Bear in mind that the values can be extracted with the $ symbol, i.e. this is an S3 class output.

Details

This is a way to see the network for some given nodes. It is useful if you have many nodes and the whole network is a bit difficult to see clearly.

See Also

mmhc.skel, SES, MMPC

Examples

Run this code
# simulate a dataset with continuous data
set.seed(1234)
dataset <- matrix(runif(1000 * 20, 1, 100), nrow = 1000 ) 
G = pc.con(dataset)$G
plota(G)
dev.new()
nei( G, c(3, 4) )
dev.new()
nei( G, c(1, 3) )

Run the code above in your browser using DataLab